﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;

namespace Minio.Extend.Db
{
    public class MEDbContext : DbContext
    {
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            string conn = Appsettings.App("DbConfig", "MySql");
            optionsBuilder.UseMySql(conn);
        }

        public DbSet<SystemFileBusinessEntity> SystemFileBusinessEntities { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<SystemFileBusinessEntity>(opt =>
            {
                opt.ToTable("SystemFileBusinessInfoes")
                .HasKey(x => x.Id);

                opt.Property(x => x.BucketName).HasMaxLength(200).IsRequired();
                opt.Property(x => x.Extension).HasMaxLength(30).IsRequired(false);
                opt.Property(x => x.ObjectName).HasMaxLength(100).IsRequired();
                opt.Property(x => x.Title).HasMaxLength(200).IsRequired();
                opt.Property(x => x.Size).IsRequired();
            });
            base.OnModelCreating(modelBuilder);
        }
    }
}
